<?php

$basepath = $_SERVER['DOCUMENT_ROOT'];
require_once($basepath. '/mapblogs/app_config/app_config.php');


$section = htmlspecialchars(strip_tags(utf8_encode($_GET['sec'])));
$category = htmlspecialchars(strip_tags(utf8_encode($_GET['category'])));
$g_course_id = htmlspecialchars(strip_tags(utf8_encode($_GET['cid'])));
$tempvar = "";


$conn = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $conn);

//$query = "select * from " . $g_mapblog_table_name . " where course_id = '" . $g_course_id . "' and section = " . $section . " and category = '" . $category . "'";

$query = "select * from " . $g_mapblog_table_name . " where course_id = '" . $g_course_id . "' and section = " . $section;

$result = mysql_query($query, $conn);
$num_result = mysql_num_rows($result);
echo
$num_result
die;

$latvar = 0;
$longvar = 0;

$tempvar = "markers = [";

$counter = 1;
while ($row = mysql_fetch_array($result))
{
	$latvar = $row["latitude"];
	$longvar = $row["longitude"];
	$namevar = $row["place_name"];
	$urlvar = $row["page_url"];
	$userid = $row["userid"];
	$thedate = $row["add_date"];
	$row_seq_no = $row["row_seq_no"];
	$category = $row["category"];
	
	$tempvar = $tempvar . "{'latitude': $latvar, 'longitude': $longvar, 'name' : '$namevar', 'url' :";
	$tempvar = $tempvar . "'$urlvar', 'userid' : '$userid', 'add_date' : '$thedate', 'row_seq_no' : '$row_seq_no', 'category' : '$category'}";
	
	if ($counter != $num_result) {
		$tempvar = $tempvar . ",";
	};
	
    $counter++;
}

$tempvar = $tempvar . "]";
echo $tempvar;

?>
